CREATE SEQUENCE seq_cubosmodlog
  INCREMENT 1
  MINVALUE 1
  MAXVALUE 9223372036854775807;


CREATE TABLE cubosmodlog
(
  id integer NOT NULL DEFAULT nextval('seq_cubosmodlog'::regclass),
  codcubosmod character varying(20),
  fechayhora timestamp without time zone DEFAULT now(), 
  codambusr character varying(2),
  codambusracc character varying(20),
  idambdb integer, 
  fechainsert timestamp without time zone, 
  fechaupdate timestamp without time zone
  
)
WITH (OIDS=TRUE);
ALTER TABLE cubosmodlog OWNER TO abacouser;

COMMENT ON TABLE cubosmodlog IS 'LOG de ejecucion de los cubos definidos en cubosmod';
COMMENT ON COLUMN cubosmodlog.id IS 'Identificador del registro';
COMMENT ON COLUMN cubosmodlog.codcubosmod IS 'Codigo del cubo';
COMMENT ON COLUMN cubosmodlog.fechayhora IS 'Fecha y hora de ejecucion';
COMMENT ON COLUMN cubosmodlog.codambusr IS 'Codigo del perfil del usuario';
COMMENT ON COLUMN cubosmodlog.codambusracc IS 'Codigo del usuario de acceso';
COMMENT ON COLUMN cubosmodlog.idambdb IS 'Identificador de la instancia';
COMMENT ON COLUMN cubosmodlog.fechainsert IS 'Fecha y hora de alta del registro';
COMMENT ON COLUMN cubosmodlog.fechaupdate IS 'Fecha y hora ultima actualizacion del registro';

CREATE TRIGGER control_audit_cubosmodlog
  BEFORE INSERT OR UPDATE OR DELETE
  ON cubosmodlog
  FOR EACH ROW
  EXECUTE PROCEDURE tg_control_audit_instancia();



-- =====================================
   SELECT aaversion('400.00');
-- =====================================

